deferred class CD_CANVAS_INITIALIZATION

inherit
	CANVAS_DRAW

feature {ANY}

	kill_canvas
		-- Destroys a previously created canvas.
		do
			int_kill_canvas(cnvs)
		end

	activate: BOOLEAN
		-- Activates a canvas for drawing. This is used only for a few drivers. 
		-- Native Window and IUP drivers will update the canvas size if the 
		-- window size has changed. Double Buffer driver will recreate the image 
		-- buffer if the window canvas size has changed. In these cases the 
		-- function MUST be called, for other drivers is useless. Return True 
		-- or False.
		local
			state: INTEGER
		do
			state := int_canvas_activate(cnvs)

			if state.is_equal(0) then
				Result := True
			else
				Result := False
			end
		end

	deactivate
		-- Called when the application has finished drawing in the canvas. It is 
		-- optional, but if used for the Native Window driver in Windows when the 
		-- handle can not be retained, the drawing can only be done again after a 
		-- "activate".	On some drivers will simply call Flush.
		do
			int_canvas_deactivate(cnvs)
		end


	-- Skip:
	-- 
	-- cdCanvasGetContext
	-- cdContextCaps
	-- cdContextType
	-- cdContextIsPlus

feature {}

	-- Internals

	int_kill_canvas (data: POINTER)
		external "plug_in"
      alias "{
         location: "${sys}/plugins"
         module_name: "iup"
         feature_name: "cdKillCanvas"
         }"
      end

	int_canvas_activate (data: POINTER): INTEGER
		external "plug_in"
      alias "{
         location: "${sys}/plugins"
         module_name: "iup"
         feature_name: "cdCanvasActivate"
         }"
      end

	int_canvas_deactivate (data: POINTER)
		external "plug_in"
      alias "{
         location: "${sys}/plugins"
         module_name: "iup"
         feature_name: "cdCanvasDeactivate"
         }"
      end

end

-- The MIT License (MIT)

-- Copyright (c) 2016 by German A. Arias

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in 
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
